home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
bmgrep.arc
/
MAKEDESC.C
< prev
next >
Wrap
Text File
|
1986-12-09
|
745b
|
27 lines
#include <stdio.h>
#include "bm.h"
#include "extern.h"
extern char * malloc();
/* makes a pattern descriptor */
struct PattDesc *MakeDesc(Pattern)
char *Pattern;
{
struct PattDesc *Desc;
Desc = (struct PattDesc *) malloc(sizeof(struct PattDesc));
if (!(Desc->Skip1 = (unsigned short int *)
malloc( sizeof(int) * (MAXCHAR + 1)))){
fprintf(stderr,"bm: can't allocate space\n");
exit(2);
} /* if */
if (!(Desc->Skip2 = (unsigned short int *)
malloc(sizeof(int) * strlen(Pattern)))){
fprintf(stderr,"bm: can't allocate space\n");
exit(2);
} /* if */
Desc->Pattern=Pattern;
Desc->PatLen = strlen(Desc->Pattern);
MakeSkip(Desc->Pattern,Desc->Skip1,
Desc->Skip2,Desc->PatLen);
return(Desc);
} /* main */